//
//  XGCollectionViewCell.m
//  Instagram
//
//  Created by monkey on 2019/4/14.
//  Copyright © 2019 itcast. All rights reserved.
//

#import <Masonry/Masonry.h>

#import "XGCollectionViewCell.h"

@interface XGCollectionViewCell ()

/// 图片
@property (nonatomic,strong) UIImageView *imageView;

@end

@implementation XGCollectionViewCell

#pragma mark - 解析数据

- (void)setFile:(AVFile *)file
{
    [XGImageManager imageForAVFile:file placeholderImage:nil imageSize:self.size completion:^(UIImage * _Nullable image) {
        self.imageView.image = image;
    }];
}

#pragma mark - 构造方法

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self setUpUI];
    }
    
    return self;
}

- (void)setUpUI
{
    self.contentView.backgroundColor = [UIColor whiteColor];
    
    [self.contentView addSubview:self.imageView];
    
    [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView);
    }];
}

#pragma mark - 懒加载

- (UIImageView *)imageView
{
    if (!_imageView) {
        _imageView = [[UIImageView alloc] init];
    }
    
    return _imageView;
}

@end
